﻿using Castle.ActiveRecord;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Online_Course.Domain
{
    [ActiveRecord]
    public class Teacher:BaseEntity<Teacher>
    {
        [Property(Length = 30, NotNull = false)]
        [Display(Name = "姓名")]
        public string Name { get; set; }

        [Property(Length = 30, NotNull = false)]
        [Display(Name = "工号")]
        public string TeacherCode { get; set; }

        [Property(Length = 30, NotNull = false)]
        [Display(Name = "电话")]
        public string Phone { get; set; }

        [Property(Length = 30, NotNull = false)]
        [Display(Name = "状态")]
        public int IsActive { get; set; }

        ///// <summary>
        ///// 任课表
        ///// </summary>
        //[BelongsTo(Column = "CourseID", Cascade = CascadeEnum.None, Lazy = FetchWhen.OnInvoke)]
        //[Display(Name = "所教课程")]
        //public Course Course { get; set; }

        //[Display(Name = "任课列表")]
        //[HasMany(typeof(Course), Table = "Course_Teacher", ColumnKey = "TeacherId", Lazy = false, Cascade = ManyRelationCascadeEnum.All)]
        //public IList<Course> CourseList { get; set; }


         //<summary>
         //教师发布课
         //</summary>
        [HasAndBelongsToMany(typeof(Course), Table = "Teacher_Course", ColumnKey = "TeacherId", ColumnRef = "CourseId", Cascade = ManyRelationCascadeEnum.None, Lazy = false)]
        [Display(Name = "教师发布课表")]
        public IList<Course> CourseList { get; set; } 
    }
}
